package cn.appsys.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import cn.appsys.pojo.AppCategory;
import cn.appsys.pojo.DataDictionary;
import cn.appsys.pojo.DevUser;
import cn.appsys.service.devUser.DevUserService;
import cn.appsys.tools.Constants;

@Controller
public class DevloginController {
	ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
	DevUserService devUserService=(DevUserService) context.getBean("devUserService");
	
	@RequestMapping(value="/dev/login")
	public String devlogin(){
		return "devlogin";
	}
	//登陆
	@RequestMapping(value="/dev/dologin",method=RequestMethod.POST)
	public String gologin(@RequestParam String devCode,
			@RequestParam String devPassword,
			HttpSession session,
			Model model){
		
		DevUser devUser=new DevUser();
		devUser.setDevCode(devCode);
		devUser.setDevPassword(devPassword);
		
		DevUser devUserResult=devUserService.devLoging(devUser);
		if(null == devUserResult){
			model.addAttribute("error","密码或账号错误");
			return "devlogin";
		}
		session.setAttribute(Constants.DEVUSER_SESSION,devUserResult);
		return "developer/main";
		//return "redirectz:/appinforlist";
	}
	
}
